package com.health.trans.util;

import cn.hutool.core.lang.func.Func0;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author nqlz
 */
public class CacheMap<K, V> extends ConcurrentHashMap<K, V> {

    public V get(K key, Func0<V> supplier) {
        if (containsKey(key)) {
            return get(key);
        }
        try {
            return (null == supplier) ? null : supplier.call();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
